[javascript - jQuery] creating nested array's on the fly
Posted
by adardesign
on Stack Overflow
See other posts from Stack Overflow
or by adardesign
Published on 2010-03-18T21:29:44Z
Indexed on
2010/03/18
21:31 UTC
Read the original article
Hit count: 401
What i am trying to do is to loop this HTML and get an nested array of this HTML values that i want to grab.
This script is just part of a whole function.
html
<div class="configureData">
<div title="Large">
<a href="yellow" title="true" rel="$55.00" name="sku22828"></a>
<a href="green" title="true" rel="$55.00" name="sku224438"></a>
<a href="Blue" title="true" rel="$55.00" name="sku22222"></a>
</div>
<div title="Large">
<a href="yellow" title="true" rel="$55.00" name="sku22828"></a>
<a href="green" title="true" rel="$55.00" name="sku224438"></a>
<a href="Blue" title="true" rel="$55.00" name="sku22222"></a>
</div>
<div title="Large">
<a href="yellow" title="true" rel="$55.00" name="sku22828"></a>
<a href="green" title="true" rel="$55.00" name="sku224438"></a>
<a href="Blue" title="true" rel="$55.00" name="sku22222"></a>
</div>
</div>
javascript
// this is part of a script.....
parseData:function(dH){
dH.find(".configureData div").each(function(indA, eleA){
colorNSize.tempSizeArray[indA] = [eleA.title,[],[],[],[]]
$(eleZ).find("a").each(function(indB, eleB){
colorNSize.tempSizeArray[indA][indB+1] = eleC.title
})
})
},
I expect the end array should look like this.
[
["large",
["yellow", "green", "blue"],
["true", "true", "true"],
["$55", "$55","$55"]
],
["Medium",
["yellow", "green", "blue"],
["true", "true", "true"],
["$55", "$55","$55"]
]
]
// and so on....
© Stack Overflow or respective owner